# coding:utf-8


class UserSyncProxy(object):
    """
    add by zhouhl 2017-09-12
    使用异步方式，同步客户的手机归属地及战区等信息
    因为不能在models里直接使用 current_app 变量，故封装一层代理
    """

    def init_app(self, app=None):
        self.app = app
        try:
            self.sync_user_producer = app.sync_user_producer
        except:
            self.sync_user_producer = None

    def send(self, body):
        if self.sync_user_producer:
            self.sync_user_producer.send(body)
